package main;

import java.io.File;
import java.util.ArrayList;

import org.ini4j.Wini;

public class NodesSuggestStrategy 
{
	private static final String SECTION_NAME = "NodesSuggestStrategy";
	
	public String xmlPath;
	public String workingDirectory;
	public String outputPath;
	public String loggerPath;
	public ArrayList<Integer> positiveExamples;
	public ArrayList<Integer> negativeExamples;
	
	
	
	
	private static void convertToArrayList(String str,String sep,ArrayList<Integer> elements)
	{
		if (str == null || sep == null || elements == null)
		{
			return;
		}
		
		String[] arr = str.split(sep);
		
		for(String element : arr)
		{
			
			elements.add(Integer.valueOf(element));
		}
	}
	
	public NodesSuggestStrategy(String strategyPath) throws Exception
	{
		Wini ini = new Wini(new File(strategyPath));
		positiveExamples = new ArrayList<Integer>();
		negativeExamples = new ArrayList<Integer>();
		
		xmlPath = ini.get(SECTION_NAME,"xmlPath",String.class);
		workingDirectory = ini.get(SECTION_NAME,"workingDirectory",String.class);
		outputPath = ini.get(SECTION_NAME,"outputPath");
		loggerPath = ini.get(SECTION_NAME,"loggerPath");

		convertToArrayList(ini.get(SECTION_NAME,"positiveExamples"),",",positiveExamples);
		convertToArrayList(ini.get(SECTION_NAME,"negativeExamples"),",",negativeExamples);
		
		if (xmlPath == null || workingDirectory == null || outputPath == null)
		{
			throw new Exception("missing necessary keys");
		}
		
	}
	
	public static void main(String[] args) throws Exception
	{
		//NodesSuggestStrategy strategy = new NodesSuggestStrategy("D:\\development\\dblab\\strategy.ini");
	}
	
}
